﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

namespace Jy123.Web.PersonalInfo
{
    public partial class PrivacyLike : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int userID; string msg = string.Empty;
            string strUserIdFromCookie = Common.Cookie.getCookie("UserID");
            if (string.IsNullOrEmpty(strUserIdFromCookie))
            {
                Response.Redirect("/");
            }
            userID = int.Parse(strUserIdFromCookie);
            //个人详细信息
            Jy123.Model.User_Info mUserInfo = new Jy123.Model.User_Info();
            Jy123.BLL.User_Info bllUserInfo = new Jy123.BLL.User_Info();
            mUserInfo = bllUserInfo.GetModel(userID);

            string strFavourite = Request.Form["Favourite"];
            string strFavMusics = Request.Form["FavMusics"];
            string strFavMovies = Request.Form["FavMovies"];
            string strFavCartoons = Request.Form["FavCartoons"];
            string strFavGames = Request.Form["FavGames"];
            string strFavSports = Request.Form["FavSports"];
            string strFavBooks = Request.Form["FavBooks"];
            string strFavAdages = Request.Form["FavAdages"];
            string strAppreciateMen = Request.Form["AppreciateMen"];
            string strPresetation = Request.Form["Presetation"];

            if (Request.Form["hidsave"] == "save")
            {
                mUserInfo.Favourite = strFavourite;
                mUserInfo.FavMusics = strFavMusics;
                mUserInfo.FavMovies = strFavMovies;
                mUserInfo.FavCartoons = strFavMovies;
                mUserInfo.FavGames = strFavGames;
                mUserInfo.FavSports = strFavSports;
                mUserInfo.FavBooks = strFavBooks;
                mUserInfo.FavAdages = strFavAdages;
                mUserInfo.AppreciateMen = strAppreciateMen;
                mUserInfo.Presentation = strPresetation;
                bllUserInfo.Update(mUserInfo);
                msg = "<script>$(function(){$.moonbox.ok('修改成功!');})</script>";
                //加入动态
                Jy123.Model.User_Main mUserForState = new Jy123.Model.User_Main();
                Jy123.BLL.User_Main bllUserForState = new Jy123.BLL.User_Main();
                mUserForState = bllUserForState.GetModel(userID);
                new Jy123.BLL.Public.State().CreateModifyUserState(mUserForState, null, (int)Jy123.BLL.Public.EnumConfig.StateActionType.ModifyUserInfo);
                //加入动态
            }
            #region 页面初始化
            StringBuilder sbHtml = new StringBuilder(Cache["user_pravacylike"].ToString());//最终写出页面的大sb
            sbHtml = sbHtml.Replace("$Header$", Cache["user_header"].ToString());//头部
            sbHtml = sbHtml.Replace("$Footer$", Cache["user_footer"].ToString());//底部
            sbHtml = sbHtml.Replace("$LeftUserCmd$", Cache["user_navigation_up"].ToString());//左侧导航
            sbHtml = sbHtml.Replace("$LeftUserFriendAdd$", Cache["user_friendadd"].ToString());//左侧直接添加好友
            //--------------------------------------------------------------------------------------------------
            sbHtml = sbHtml.Replace("$Favourite$",mUserInfo.Favourite);
            sbHtml = sbHtml.Replace("$FavMusics$", mUserInfo.FavMusics);
            sbHtml = sbHtml.Replace("$FavMovies$", mUserInfo.FavMovies);
            sbHtml = sbHtml.Replace("$FavCartoons$", mUserInfo.FavCartoons);
            sbHtml = sbHtml.Replace("$FavGames$", mUserInfo.FavGames);
            sbHtml = sbHtml.Replace("$FavSports$", mUserInfo.FavSports);
            sbHtml = sbHtml.Replace("$FavBooks$", mUserInfo.FavBooks);
            sbHtml = sbHtml.Replace("$FavAdages$", mUserInfo.FavAdages);
            sbHtml = sbHtml.Replace("$AppreciateMen$", mUserInfo.AppreciateMen);
            sbHtml = sbHtml.Replace("$Presetation$", mUserInfo.Presentation);
            #endregion
            Response.Write(sbHtml.ToString()+msg);
        }
    }
}
